package org.dreamwork.jasmine2.web.controls.chart;

import org.dreamwork.jasmine2.annotation.WebControlTemplate;
import org.dreamwork.jasmine2.util.StringConverter;
import org.dreamwork.jasmine2.web.controls.chart.settings.ChartSetting;
import org.dreamwork.jasmine2.web.controls.chart.settings.ChartType;
import org.dreamwork.jasmine2.web.controls.chart.settings.ColumnChartSetting;
import org.dreamwork.jasmine2.web.controls.chart.settings.template.ColumnChartTemplate;

/**
 * Created by IntelliJ IDEA.
 * User: seth
 * Date: 2010-5-12
 * Time: 10:36:03
 */
@WebControlTemplate (ColumnChartTemplate.class)
public class ColumnChart extends LineChart {
    private String type = "column";
    private int frequency = 1;
    private int rotate = 0;
    private int depth = 15;
    private int alpha = 100;
    private boolean use3D = true;
    private String unit;

    private ColumnChartSetting setting = new ColumnChartSetting ();

    public ColumnChart () {
        title = "Column & Bar Chart";
    }


    @Override
    protected String getSWFName () {
        return "column";
    }

    @Override
    protected ChartSetting getSetting () {
        setting.setType (type);
        setting.setRotate (rotate);
        setting.setFrequency (frequency);
        if (!StringConverter.isEmpty (unit)) setting.setUnit (unit);
        if (use3D && depth > 0) setting.setDepth (depth);
        if (alpha > 0 && alpha < 100) setting.setAlpha (alpha);
        return setting;
    }

    @Override
    protected ChartType getChartType () {
        return ChartType.Column;
    }

    public String getType () {
        return type;
    }

    public void setType (String type) {
        this.type = type;
    }

    public int getFrequency () {
        return frequency;
    }

    public void setFrequency (int frequency) {
        this.frequency = frequency;
    }

    public int getRotate () {
        return rotate;
    }

    public void setRotate (int rotate) {
        this.rotate = rotate;
    }

    public String getUnit () {
        return unit;
    }

    public void setUnit (String unit) {
        this.unit = unit;
    }

    public int getDepth () {
        return depth;
    }

    public void setDepth (int depth) {
        this.depth = depth;
    }

    public boolean isUse3D () {
        return use3D;
    }

    public void setUse3D (boolean use3D) {
        this.use3D = use3D;
    }

    public int getAlpha () {
        return alpha;
    }

    public void setAlpha (int alpha) {
        this.alpha = alpha;
    }

    @Override
    public void applyTemplate () {
        if (template == null) return;
        setting = (ColumnChartSetting) ((ColumnChartTemplate) template).buildChartSetting ();
    }
}